package view;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class MainFrame extends JFrame implements ActionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
    private JTabbedPane tabbed;
	
	public MainFrame() {
		// TODO Auto-generated constructor stub
		setTitle("学生管理系统");
		setSize(1000, 800);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		getToolkit();
		Toolkit tk=Toolkit.getDefaultToolkit();
		Image i=tk.getImage(this.getClass().getResource("../image/icon.jpg"));
		this.setIconImage(i);
		
		String[] mbName={"个人信息","表格信息","帮助"};
		String[][]  itemName={{"个人资料"},{"学生信息","部门信息","课程信息"},{"版本"}};
		JMenuBar mb=new JMenuBar();
		for(int n=0;n<mbName.length;n++){
			JMenu menu=new JMenu(mbName[n]);
			menu.setFont(new Font("微软雅黑", Font.BOLD, 15));
			mb.add(menu);
			for(int j=0;j<itemName[n].length;j++){
				JMenuItem itemMenu=new JMenuItem(itemName[n][j]);
				itemMenu.addActionListener(this);
				menu.add(itemMenu);
			}
		}
		setJMenuBar(mb);
		
		tabbed=new JTabbedPane();
		add(tabbed);
		
		JPanel welpanel=new JPanel();
		welpanel.setLayout(new BorderLayout());
		JLabel lab=new JLabel(LoginFrame.tfText() + ",欢迎您登陆学生管理系统！");
		lab.setHorizontalAlignment(JLabel.CENTER);
		lab.setFont(new Font("微软雅黑", Font.BOLD, 20));
		welpanel.add(lab,BorderLayout.CENTER);
		tabbed.add("登陆页面", welpanel);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		if(e.getActionCommand()=="个人资料"){
			
		}
		
		if(e.getActionCommand()=="学生信息"){
			Student_Info_Panel sipanel=new Student_Info_Panel();
			tabbed.addTab("学生信息", sipanel);
		}
		
		if(e.getActionCommand()=="部门信息"){
			JPanel panel=new JPanel();
			tabbed.addTab("部门信息", panel);
			tabbed.setComponentZOrder(panel, 0);
		}
		
		if(e.getActionCommand()=="课程信息"){
			JPanel panel=new JPanel();
			tabbed.addTab("课程信息", panel);
		}
		
		if(e.getActionCommand()=="版本"){
			JOptionPane.showMessageDialog(this, "Version  : 1.0");
		}
	}
}
